﻿using System;
using System.Linq;
using SuppKids.Core.Reporting.Excel;

namespace SuppKids.Core.Reporting
{
	public class ReportGeneratorFactory
	{
		private readonly IReportGenerator[] reportGenerators;

		public ReportGeneratorFactory(IReportGenerator[] reportGenerators)
		{
			this.reportGenerators = reportGenerators;
		}

		public IReportGenerator GetReportGenerator(ReportType reportType, ReportFormat reportFormat)
		{
			switch (reportFormat)
			{
				case ReportFormat.Excel:
					switch (reportType)
					{
						case ReportType.SkladDaily:
							return reportGenerators.OfType<SkladDailyReportGenerator>().Single();
						case ReportType.SkladMonthly:
							return reportGenerators.OfType<SkladMonthlyReportGenerator>().Single();
						case ReportType.MoveProducts:
							return reportGenerators.OfType<MoveProductsReportGenerator>().Single();
                        case ReportType.AllProducts:
                            return reportGenerators.OfType<AllProductsReportGenerator>().Single();
						case ReportType.Parents:
							return reportGenerators.OfType<ParentsReportGenerator>().Single();
                        case ReportType.ReturnProduct:
                            return reportGenerators.OfType<ReturnProductGenerator>().Single();
						case ReportType.MenuRequirement:
							return reportGenerators.OfType<MenuRequirementReportGenerator>().Single();
						case ReportType.NormaPitaniya:
							return reportGenerators.OfType<NormaPitaniyaReportGenerator>().Single();
						default:
							throw new ArgumentOutOfRangeException("reportType");
					}
				default:
					throw new ArgumentOutOfRangeException("reportFormat");
			}
		}
	}
}
